<?php
class Controller_Product extends Core_Controller
{

	public function _add()
    {
        $this->view->output = array
        (
            "success" => $this->request->getPostData('product') == 'fail' ? false : true,
            "message" => "Product ".$this->request->getPostData('product').
                " succesfully added"
        );
    }

    public function _update()
    {
        Core_Logger::write(print_r($this->request->getPostData(), true));
        $this->view->output = array
        (
            "success" => $this->request->getPostData('product') == 'fail' ? false : true,
            "message" => "Product ".$this->request->getPostData('product').
                " succesfully updated",
            'additional' => $this->request->getPostData()
        );
    }

    public function _load()
    {
        $this->view->output = array(
            'success' => true
            ,'message' => ''
            ,'data' => array(
                array('productId' => null, 'product' => 'All')
                , array('productId' => 10, 'product' => 'Netpak - Legacy')
                , array('productId' => 20, 'product' => 'EmvHost Online')
                , array('productId' => 30, 'product' => 'Netpak 2')
                , array('productId' => 40, 'product' => 'Konffiliittymä')
                , array('productId' => 50, 'product' => 'Matador')
                , array('productId' => 60, 'product' => 'Cekab')
                , array('productId' => 70, 'product' => 'Prepaid')
            )
        );
    }

    public function _getProducts()
    {
        return $this->_load();
    }
}